#%RAML 1.0
title: 设备相关
baseUri: /api/osinstall/{version}
version: v1
mediaType: application/json

/device/batchAdd:
  post:
    description: 批量录入设备(SN存在的情况下，会覆盖原有信息)
    queryParameters:
      Sn:
        description: SN
        type: string
        required: true
      Hostname:
        description: hostname
        type: string
        required: true
      Ip:
        description: IP
        type: string
        required: true
      NetworkID:
        description: network表ID
        type: number
        required: true
      ManageIp:
        description: 管理IP
        type: string
        required: false
      ManageNetworkID:
        description: manage_network表ID
        type: number
        required: false
      OsID:
        description: os_config表ID
        type: number
        required: true
      HardwareID:
        description: hardware表ID
        type: number
        required: false
      SystemID:
        description: system表ID
        type: number
        required: true
      LocationID:
        description: location表ID，如果没有位置，则传0
        type: string
        required: true
      AssetNumber:
        description: 财编
        type: string
        required: false
      IsSupportVm:
        description: 是否支持安装虚拟机(Yes|No)，默认为 No
        type: string
        required: false
      AccessToken:
        description: 调用登录API时，生成的授权AccessToken
        type: string
        required: true
      
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
              }


/device/list:
  post:
    description: 获取列表
    queryParameters:
      Limit:
        description: 页容量
        type: number
        required: true
      Offset:
        description: 从第几行开始
        type: number
        required: true
      Keyword:
        description: 搜索关键字，可根据sn,hostname,ip,安装批次号搜索；搜索多条信息以\n隔开
        type: string
        required: false
      BatchNumber:
        description: 批次号
        type: string
        required: false
      OsID:
        description: os_config表ID
        type: number
        required: false
      HardwareID:
        description: hardware表ID
        type: number
        required: false
      SystemID:
        description: system_config表ID
        type: number
        required: false
      Status:
        description: 状态(pre_install 待安装,installing 安装中,success 安装成功,failure 安装失败)
        type: number
        required: false
      StartUpdatedAt:
        description: 更新时间(开始)
        type: string
        required: false
      EndUpdatedAt:
        description: 更新时间(结束)
        type: string
        required: false
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
                "Content":{
                  "list":{}
                  "recordCount":100
                },
              }


/device/view:
  post:
    description: 获取详情
    queryParameters:
      ID:
        description: ID
        type: number
        required: true
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
                "Content":{
                  ...
                },
              }


/device/batchDelete:
  post:
    description: 批量删除
    queryParameters:
      ID:
        description: ID
        type: number
        required: true
      AccessToken:
        description: 调用登录API时，生成的授权AccessToken
        type: string
        required: true
    
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
              }

/device/batchReInstall:
  post:
    description: 批量重新安装
    queryParameters:
      ID:
        description: ID
        type: number
        required: true
      AccessToken:
        description: 调用登录API时，生成的授权AccessToken
        type: string
        required: true
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
              }

/device/batchCancelInstall:
  post:
    description: 批量取消安装
    queryParameters:
      ID:
        description: ID
        type: number
        required: true
      AccessToken:
        description: 调用登录API时，生成的授权AccessToken
        type: string
        required: true
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
              }


/device/getDeviceBySn:
  get:
    description: 根据SN获取设备信息
    queryParameters:
      sn:
        description: SN
        type: string
        required: true
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Content": {
                  "ID": 2,
                  "CreatcedAt": "2016-03-11T11:55:50+08:00",
                  "UpdatedAt": "2016-03-11T11:55:50+08:00",
                  "BatchNumber": "20160311001",
                  "Sn": "5GD4C3X",
                  "Hostname": "web-db",
                  "Ip": "192.168.1.1",
                  "ManageIp": "192.168.100.1",
                  "NetworkID": 1,
                  "ManageNetworkID": 1,
                  "OsID": 1,
                  "HardwareID": 1,
                  "SystemID": 1,
                  "Location": "",
                  "LocationID": 7,
                  "AssetNumber": "CB201503110001",
                  "Status": "success",  //状态：pre_install 准备安装，installing 正在安装，success 安装成功，failure 安装失败
                  "InstallProgress": 1, //安装进度，1表示 100%
                  "InstallLog": "",
                  "UserID": 1
                },
                "Message": "操作成功",
                "Status": "success"
              }

/device/importDeviceForOpenApi:
  post:
    description: 录入设备(针对第三方系统)
    queryParameters:
      Sn:
        description: SN
        type: string
        required: true
      Hostname:
        description: hostname
        type: string
        required: true
      Ip:
        description: IP
        type: string
        required: true
      ManageIp:
        description: 管理IP
        type: string
        required: false
      OsName:
        description: 操作系统名称
        type: string
        required: true
      HardwareName:
        description: 硬件配置模板全称，如 Dell-PowerEdge R420
        type: string
        required: false
      SystemName:
        description: 系统模板名称
        type: string
        required: true
      Location:
        description: 地址，各层级地址间以"-"隔开。不存在的地址会自动补充到地址模板库。如：杭州-留下机房-A101-10机柜
        type: string
        required: true
      AssetNumber:
        description: 财编
        type: string
        required: false
      UserID:
        description: 用户ID，默认为0，可以不传
        type: number
        required: false
      IsSupportVm:
        description: 是否支持安装虚拟机(Yes|No)，默认为 No
        type: string
        required: false
      AccessToken:
        description: 调用登录API时，生成的授权AccessToken
        type: string
        required: true
      
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
              }


/device/scan/list:
  post:
    description: 获取【资源池】设备列表信息
    queryParameters:
      Limit:
        description: 页容量
        type: number
        required: true
      Offset:
        description: 从第几行开始
        type: number
        required: true
      Keyword:
        description: 搜索关键字，可根据SN、厂商、产品名称、型号、DHCP IP搜索；搜索多条信息以\n隔开
        type: string
        required: false
      Company:
        description: 设备厂商
        type: string
        required: false
      ModelName:
        description: 设备型号
        type: string
        required: false
      CpuRule:
        description: CPU字段搜索规则，可传 >,<,=,!=，要与CPU参数结合使用
        type: string
        required: false
      Cpu:
        description: CPU核数
        type: string
        required: false
      MemoryRule:
        description: 内存字段搜索规则，可传 >,<,=,!=，要与Memory参数结合使用
        type: string
        required: false
      Memory:
        description: 内存大小，单位 MB
        type: string
        required: false
      DiskRule:
        description: 硬盘字段搜索规则，可传 >,<,=,!=，要与Disk参数结合使用
        type: string
        required: false
      Disk:
        description: 硬盘大小，单位 GB
        type: string
        required: false
      IsShowEnteredDevice:
        description: 是否显示已录入到设备列表的信息，默认为No，要显示请传 Yes
        type: string
        required: false
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "Status": "success",
                "Message": "",
                "Content":{
                  "list":{}
                  "recordCount":100
                },
              }
